#include"widget.h"
#include"gamewidget.h"
#include<QDebug>


Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->resize(891,510);
    this->setWindowTitle("贪吃蛇");
    this->setWindowIcon(QIcon("C:/Users/renyi/WindowPicture.jpg"));
    QPalette palette;
    palette.setBrush(QPalette::Background,QBrush(QPixmap("C:/Users/renyi/Back.jpg")));
    palette.setBrush(QPalette::Background,QBrush(QPixmap("C:/Users/renyi/Back2.jpg")));
    this->setStyleSheet("C:/Users/renyi/GameBack.jpg");
    this->setPalette(palette);

    startPush=new QPushButton(this);
    exitPush=new QPushButton(this);
    startPush->setIconSize(QSize(920,45));
    startPush->setGeometry(400,360,90,45);
    startPush->setIcon(QIcon("C:/Users/renyi/Start.png"));
    startPush->setFlat(1);//去掉按钮的边框
    exitPush->setIconSize(QSize(90,45));
    exitPush->setGeometry(400,420,90,45);
    exitPush->setIcon(QIcon("C:/Users/renyir/Exit.png"));
    exitPush->setFlat(1);

    exitBox=new QMessageBox;
    connect(exitPush,SIGNAL(clicked(bool)),this,SLOT(M_exitPush()));
    connect(startPush,SIGNAL(clicked(bool)),this,SLOT(M_startPush()));
}

void Widget::M_startPush()
{
    gamewindow=new Gamewidget(this);
    gamewindow->show();
}
void Widget::M_exitPush()
{
    if(QMessageBox::Yes==QMessageBox::question(this,"Tips：","Do you want to leave th ox:⒋gamewidget.h中的代码:No"))
    {
                                               
   delete this;
         exit(0);
    }
}
 Widget::~Widget(){}
